< previous page page_173 next page >

Page 173
Now enter the code in Listing 5.50 to the cmdFind_Click event. When executed, this code queries the user to enter an appropriate search string.
Type.gifListing 5.50. Finding data records.
Private Sub cmdFind_Click()
    '
    Dim nResult As Integer
    Dim cFind As String
    Dim cBookMark As String
    '
    cFind = InputBox("Enter Search String:", "CompanyMaster FIND")
    If Len(cFind) > 0 Then
       cBookMark = Data1.Recordset.Bookmark
       Data1.Recordset.FindFirst cFind
       If Data1.Recordset.NoMatch Then
          MsgBox "Can't Find [" & cFind & "]", vbExclamation, "Find Error"
          Data1.Recordset.Bookmark = cBookMark
       End If
    End If
    '
End Sub
The code in Listing 5.51 should be entered into the cmdRestore_Click event to restore the controls to their original value when the cmdRestore command button is selected.
Type.gifListing 5.51. Restoring the data controls.
Private Sub cmdRestore_Click()
    '
    nAddRec = False
    Data1.UpdateControls ' restore controls from table
    '
End Sub
Now enter code to save the data. Use Listing 5.52 as a guide and enter this code into the cmdUpdate_Click event.
Type.gifListing 5.52. Writing a record.
Private Sub cmdUpdate_Click()
    '
    If nAddRec = False Then
       Data1.Recordset.Edit
    End If
    '
continues

 
< previous page page_173 next page >

If you like this book, buy it!